<?php
class Login_Model_Login {
	
	private $login;
	private $logged;
	private $forgot;
	private $registry;
	private $registred;
	private $forgoten;
	
	public function __construct(){

		$this->login = new Login_Data_Login;
		$this->logged = new Login_Model_Logged;
		$this->forgot = new Login_Data_Forgot;
		$this->registry = new Login_Data_Registry;
		$this->registred = new Login_Model_Registred;
		$this->forgoten = new Login_Data_Forgoten();
	}
	
	public function getPage($name, array $postVars = null){
		try {
			switch($name){
				case "login":
					return $this->showLoginForm();
					break;
				case "logged":
					$this->loggedAction($postVars);
					break;
				case "registry":
					return $this->showRegistryForm();
					break;
				case "forgot":
					return $this->showForgotForm();
					break;
				case "registred":
					$this->registredAction($postVars);
					break;
				case "forgoten":
					$this->forgotenAction($postVars);
				default:
					echo '<meta http-equiv="Refresh" content="0;url='.SERVER_ROOT.'?login&page=login">';
			}
		}
		catch(Exception $e){
			echo $e->getMessage();
		}
	}
	
	private function forgotenAction(array $postVars){
		return $this->forgoten->updatePassword($postVars);
	}
	
	private function registredAction(array $postVars){
		return $this->registred->addRegistredValues($postVars);
	}
	
	private function showRegistryForm(){
		return $this->registry->getData();
	}
	
	private function showForgotForm(){
		return $this->forgot->getData();		
	}
	
	private function loggedAction(array $postVars){
		return $this->logged->getSessionValues($postVars);
	}
	
	private function showLoginForm(){
		return $this->login->getData();
	}
	
}